<?php

class Ext_Captcha_Check
{
    protected $_captcha;
    
    public function __construct($captcha)
    {
        $this->_captcha = $captcha;
    }
    
    public function check()
    {
        $result = array(
            'code'        => Ext_Captcha_Check_Result::FAILURE,
            'messages'    => array(),
        );
        
        $validator = new Ext_Captcha_Validate();
        if(!$validator->isValid($this->_captcha)){
            $result['messages'] = $validator->getMessages();
            return new Ext_Captcha_Check_Result($result['code'], $result['messages']);
        }

        $result['code'] = Ext_Captcha_Check_Result::SUCCESS;
        return new Ext_Captcha_Check_Result($result['code'], $result['messages']);
    }
}
